package com.imay.live.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.imay.live.R;
import com.imay.live.view.indicator.IndicatorViewPager;

/**
 * Created by Administrator on 2017/8/14 0014.
 */

public class DynamicsIndicatorAdapter extends IndicatorViewPager.IndicatorFragmentPagerAdapter {

    private final Context mContext;
    private String[] names;
    private int layoutid;

    public DynamicsIndicatorAdapter(Context context, FragmentManager fragmentManager, String[] names) {
        this(context, fragmentManager, names, R.layout.view_indicator_tab3);
    }

    public DynamicsIndicatorAdapter(Context context, FragmentManager fragmentManager, String[] names, int layoutid) {
        super(fragmentManager);
        this.names = names;
        mContext = context;
        this.layoutid = layoutid;
    }

    @Override
    public int getCount() {
        return names.length;
    }

    @Override
    public View getViewForTab(int position, View convertView, ViewGroup container) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(layoutid, container, false);
        }
        TextView textView = (TextView) convertView;
        textView.setText(names[position % names.length]);
        return convertView;
    }

    @Override
    public Fragment getFragmentForPage(int position) {
        return null;
    }
}

